﻿<Page
    x:Class="Sidvall.UI.Uwp.Test.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sidvall.UI.Uwp.Test"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vms="using:Sidvall.UI.Uwp.Test.ViewModels"
    xmlns:converters="using:Sidvall.UI.Uwp.Converters" 
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
    xmlns:controls2="using:Sidvall.UI.Uwp.Controls"
    mc:Ignorable="d">

    <Page.Resources>
        <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
        <converters:StringToAssetConverter x:Key="StringToAssetConverter" Size="16" />
    </Page.Resources>

    <Grid d:DataContext="{d:DesignInstance vms:MainWindowViewModel, IsDesignTimeCreatable=True}" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState>
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="1024" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="HamburgerMenu.DisplayMode" Value="CompactInline" />
                        <Setter Target="HamburgerMenu.IsPaneOpen" Value="True" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState>
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="720" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="HamburgerMenu.DisplayMode" Value="CompactOverlay" />
                        <Setter Target="HamburgerMenu.IsPaneOpen" Value="False" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState>
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="HamburgerMenu.DisplayMode" Value="Overlay" />
                        <Setter Target="HamburgerMenu.IsPaneOpen" Value="False" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <controls:HamburgerMenu x:Name="HamburgerMenu" ItemsSource="{Binding MenuItems}" OptionsItemsSource="{Binding OptionItems}"
                                PaneBackground="{ThemeResource AppBarBackground}" ItemClick="HamburgerMenu_ItemClick" OptionsItemClick="HamburgerMenu_OptionsItemClick"
                                IsEnabled="{Binding IsNotBusy}">
            <controls:HamburgerMenu.ItemTemplate>
                <DataTemplate>
                    <Grid Width="240" Height="48">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="48"></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition Width="48"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Source="{Binding Image1, Converter={StaticResource StringToAssetConverter}}" 
                               HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" />
                        <TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="16" VerticalAlignment="Center"/>
                        <Image Grid.Column="2" Source="{Binding Image2, Converter={StaticResource StringToAssetConverter}}" 
                               HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" />
                    </Grid>
                </DataTemplate>
            </controls:HamburgerMenu.ItemTemplate>
            <controls:HamburgerMenu.OptionsItemTemplate>
                <DataTemplate>
                    <Grid Width="240" Height="48">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="48"></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition Width="48"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Source="{Binding Image1, Converter={StaticResource StringToAssetConverter}}" 
                               HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" />
                        <TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="16" VerticalAlignment="Center"/>
                        <Image Grid.Column="2" Source="{Binding Image2, Converter={StaticResource StringToAssetConverter}}" 
                               HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" />
                    </Grid>
                </DataTemplate>
            </controls:HamburgerMenu.OptionsItemTemplate>
            <Frame x:Name="RootFrame" x:FieldModifier="Public">
            </Frame>
        </controls:HamburgerMenu>
        <controls2:BusyIndicatorControl HeaderCaption="{Binding IsBusyMessage}" Visibility="{Binding IsBusyAndStarted, Converter={StaticResource BooleanToVisibilityConverter}}" />
    </Grid>
</Page>
